<template>
  <a-card :bordered="true" style="margin-bottom: 30px" title="时间选择框">
    <a-row style="margin-bottom: 10px">
      <a-col :span="4">
        <div class="example-side">
          demo1:日期选择
        </div>
      </a-col>
      <a-col :span="8">
        <div class="example-side">
          <!--------------------------------------------------------------------------------------demo1---start-->
          <a-date-picker
            placeholder="请选择日期"
            style="width: 60%"
            v-model="demo1.select1"
          />
          <!--------------------------------------------------------------------------------------demo1---end-->
          <a-button @click="() => demo1.select1 = undefined" style="margin-left: 8px">重置</a-button>
        </div>
      </a-col>
      <a-col :span="12" class="example-side">
        <div>
          当前时间: {{ demo1.select1 }}
        </div>
        <div>
          格式化后: {{ demo1.select1 | moment('YYYY-MM-DD') }}
        </div>
      </a-col>
    </a-row>

    <a-row style="margin-bottom: 10px">
      <a-col :span="4">
        <div class="example-side">
          demo2:日期时间选择
        </div>
      </a-col>
      <a-col :span="8">
        <div class="example-side">
          <!--------------------------------------------------------------------------------------demo2---start-->
          <a-date-picker
            :showTime="{ defaultValue: moment('00:00:00', 'HH:mm:ss') }"
            format="YYYY-MM-DD HH:mm:ss"
            placeholder="请选择日期时间"
            style="width: 60%"
            v-model="demo2.select1"
          />
          <!--------------------------------------------------------------------------------------demo2---end-->
          <a-button @click="() => demo2.select1 = undefined" style="margin-left: 8px">重置</a-button>
        </div>
      </a-col>
      <a-col :span="12" class="example-side">
        <div>
          当前时间: {{ demo2.select1 }}
        </div>
        <div>
          格式化后: {{ demo2.select1 | moment() }}
        </div>
      </a-col>
    </a-row>

    <a-row style="margin-bottom: 10px">
      <a-col :span="4">
        <div class="example-side">
          demo3:日期段
        </div>
      </a-col>
      <a-col :span="8">
        <div class="example-side">
          <!--------------------------------------------------------------------------------------demo3---start-->
          <a-range-picker
            format="YYYY-MM-DD"
            style="width: 60%;"
            v-model="demo3.select1"
          />
          <!--------------------------------------------------------------------------------------demo3---end-->
          <a-button @click="() => demo3.select1 = []" style="margin-left: 8px">重置</a-button>
        </div>
      </a-col>
      <a-col :span="12" class="example-side">
        <div>
          当前选择: {{ demo3.select1 }}
        </div>
        <div>
          格式化后: {{ demo3.select1[0] | moment('YYYY-MM-DD') }} ~ {{ demo3.select1[1] | moment('YYYY-MM-DD') }}
        </div>
      </a-col>
    </a-row>

    <a-row style="margin-bottom: 10px">
      <a-col :span="4">
        <div class="example-side">
          demo4:时间段
        </div>
      </a-col>
      <a-col :span="8">
        <div class="example-side">
          <!--------------------------------------------------------------------------------------demo3---start-->
          <a-range-picker
            :showTime="{
              defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')]
            }"
            format="YYYY-MM-DD"
            style="width: 60%;"
            v-model="demo4.select1"
          />
          <!--------------------------------------------------------------------------------------demo3---end-->
          <a-button @click="() => demo4.select1 = []" style="margin-left: 8px">重置</a-button>
        </div>
      </a-col>
      <a-col :span="12" class="example-side">
        <div>
          当前选择: {{ demo4.select1 }}
        </div>
        <div>
          格式化后: {{ demo4.select1[0] | moment() }} ~ {{ demo4.select1[1] | moment() }}
        </div>
      </a-col>
    </a-row>
  </a-card>
</template>

<script>
import moment from 'moment'

export default {
  name: 'OrdinarySelectBox',
  components: {},
  data () {
    return {
      moment,
      demo1: {
        select1: undefined
      },
      demo2: {
        select1: undefined
      },
      demo3: {
        select1: []
      },
      demo4: {
        select1: []
      }
    }
  }
}
</script>

<style scoped>
</style>
